package create;

class MyThread extends Thread {

    @Override
    public void run() {
        long result = 0;
        for (int i = 1; i <= 100; i++) {
            result += i;
            try {
                Thread.sleep(50); //当前线程休眠50毫秒
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("result=" + result);
    }
}

public class ThreadDemo {
    public static void main(String[] args) {

        Thread th = new MyThread();
        th.start();
    }
}
